

// 重置
$('body').on('click', '#reset-filter-btn', function() {
  $(this).parents('.filter-detail').find('input').val('');
});


var Batchwithdrawal = $('#Batchwithdrawal'),
    deletion = $('#deletion'),
    status,
    selectId,
    sumId = [];

    Batchwithdrawal.on('click',function(){
    	console.log($('.check-one:checked').length)
		if ($('.check-one:checked').length > 0) {
			$.each($('.check-one:checked'),function(i,val){
				selectId = $(val).data('id');
				if (sumId.indexOf(selectId) == -1 && sumId.length > 1) {
					sumId.push(selectId);
				}else if (sumId.indexOf(selectId) == -1 && sumId.length <= 1){
					sumId.push(selectId);
				}
			})
			var str = '确认审核通过该新闻？';
		   	$.confirm({
		   		msg:str,
		   		confirm:function(){
					$.ajax({
			    		url:'/Admin/Information/News/batchChangeNewsStatus',
			    		type:'post',
			    		data:{ids:sumId,operate:1,status:1,check:1},
			    		dataType:'json',
			    		success:function(json){
			    			console.log(json)
			    			if (json.code == 1) {
			    				$.alert(json.msg);
			    				window.location.reload();
			    			}else{
			    				$.alert(json.msg);
			    			}
			    		},
			    		error:function(json){

			    		}
			    	})
				}
		   	})
			
		}else{
			$.alert('请至少选择一条！')
    		return false;
		}
    	
    })


   var firstdepart = $('.first-depart'),
		seconddepart = $('.second-depart'),
		threedepart = $('.three-depart'),
		firstForm = $('#first-depart'),
		secondForm = $('#second-depart'),
		threeForm = $('#three-depart'),
		imgModal = $('#imgModal');

var reason = $('#first-item');
    deletion.on('click',function(){
    	console.log($('.check-one:checked').length)
		if ($('.check-one:checked').length > 0) {
			$.each($('.check-one:checked'),function(i,val){
				selectId = $(val).data('id');
				if (sumId.indexOf(selectId) == -1 && sumId.length > 1) {
					sumId.push(selectId);
				}else if (sumId.indexOf(selectId) == -1 && sumId.length <= 1){
					sumId.push(selectId);
				}
			})
			imgModal.removeClass('hide');
			firstdepart.addClass('hide');
			seconddepart.addClass('hide');
			threedepart.removeClass('hide');
			reason.val('');
			var idsth = $('#idsth').val(sumId);
			var operateth = $('#operateth').val('1');
			var statusth = $('#statusth').val('4');
			$('#idth').attr('name','');
			
		}else{
			$.alert('请至少选择一条！');
    		return false;
		}
    	

    })

    $('.three-depart-k').on('click',function(){

    		$.ajax({
	    		url:'/Admin/Information/News/batchChangeNewsStatus',
	    		type:'post',
	    		data:{ids:sumId,operate:1,status:4,reason:$('#three-item').val(),check:1},
	    		dataType:'json',
	    		success:function(json){
	    			if (json.code == 1) {
		              $.alert(json.msg);
		              window.location.reload();
		            }else{
		            	$.alert(json.msg);
		            }
	    		},
	    		error:function(json){

	    		}
	    	})
    })


    // 单个通过

   $('.pass').on('click',function(){
   	var str = '确认审核通过该新闻？';
   	var id = $(this).data('id');
   	
   	$.confirm({
   		msg:str,
   		confirm:function(){
			$.ajax({
	    		url:'/Admin/Information/News/changeNewsStatus',
	    		type:'post',
	    		data:{id:id,operate:1,status:1,check:1},
	    		dataType:'json',
	    		success:function(json){
	    			console.log(json)
	    			if (json.code == 1) {
	    				$.alert(json.msg);
	    				window.location.reload();
	    			}else{
	    				$.alert(json.msg);
	    			}
	    		},
	    		error:function(json){

	    		}
	    	})
		}
   	})
   }) 


       // 单个拒绝

   $('.refuse').on('click',function(){
   	reason.val('');
   	imgModal.removeClass('hide');
	firstdepart.removeClass('hide');
	seconddepart.addClass('hide');
	threedepart.addClass('hide');
	$('#ids').attr('name','');
	$('#operate').val('1');
	$('#status').val('4');	
   	var id = $(this).data('id');
  
   	$('#id').val(id);

   }) 
   // 提交
		firstForm.validate();
		firstForm.on('submit',function(){
			try {
				if (firstForm.valid()) {
					firstForm.submitForm();
				}

			}catch(e){
				console.log(e)
			}

			return false;
		})

          // 单个撤稿

   $('.withdrawal').on('click',function(){

   	imgModal.removeClass('hide');
	firstdepart.addClass('hide');
	seconddepart.removeClass('hide');
	threedepart.addClass('hide');

   	var id = $(this).data('id');
   	$('#id1').val(id);
   	$('#operate1').val('1');
	$('#status1').val('2');
   }) 

   	// 提交
	secondForm.validate();
	secondForm.on('submit',function(){
		try {
			if (secondForm.valid()) {
				secondForm.submitForm();
			}

		}catch(e){
			console.log(e)
		}

		return false;
	})